import { NavigateFunction } from 'react-router-dom';

let navigateFn: NavigateFunction;

export const setNavigate = (navigate: NavigateFunction) => {
  navigateFn = navigate;
};

export const RouterUtils = {
  toHome() {
    navigateFn('/');
  },
  toServo(id: number | string) {
    navigateFn(`/servo/${id}`);
  },
  back() {
    navigateFn(-1);
  },
};
